package xin.yangshuai.springmvcrequestparameter.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import xin.yangshuai.springmvcrequestparameter.entity.Person;
import xin.yangshuai.springmvcrequestparameter.vo.Teacher;

import java.util.List;

/**
 * ParameterController
 *
 * @author shuai
 * @date 2020/5/17
 */
@Controller
public class ParameterController {

    @GetMapping("list")
    public String list() {
        return "person/list";
    }

    @GetMapping("form1")
    public String form1(ModelMap modelMap, String name, Integer age) {
        System.out.println("name -> " + name);
        System.out.println("age -> " + age);
        modelMap.put("display0", name);
        modelMap.put("display1", age);
        return "person/display";
    }

    @GetMapping("form2")
    public String form2(ModelMap modelMap, Person person) {
        System.out.println("person -> " + person);
        modelMap.put("display0", person);
        return "person/display";
    }

    @GetMapping("form3")
    public String form3(ModelMap modelMap, String[] name, Integer[] age) {
        System.out.println("name -> " + name);
        System.out.println("age -> " + age);
        modelMap.put("display0", name);
        modelMap.put("display1", age);
        return "person/display";
    }

    @GetMapping("form4")
    public String form4(ModelMap modelMap, Teacher teacher) {
        System.out.println("teacher -> " + teacher);
        modelMap.put("display0", teacher);
        return "person/display";
    }
}
